package svc

import (
	"github.com/tal-tech/go-zero/core/stores/sqlx"
	"github.com/tal-tech/go-zero/zrpc"
	"newwater/app/soil/cmd/rpc/internal/config"
	"newwater/app/soil/model"
	"newwater/app/user/cmd/rpc/user"
)

type ServiceContext struct {
	Config config.Config
	WaterSoil model.WaterSoilModel
	UserRpc user.User
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,
		WaterSoil: model.NewWaterSoilModel(sqlx.NewMysql(c.Mysql.DataSource), c.CacheRedis),
		UserRpc:   user.NewUser(zrpc.MustNewClient(c.UserRpcConf)),
	}
}
